<html>
<head>
<title>MipSmooth</title>
<link rel="stylesheet" type="text/css" href="../../avisynth.css">
<!--
Automatically generated, don't change:
$Id: mipsmooth.htm,v 1.2 2004/08/13 21:57:25 wilbertd Exp $ 
-->
</head>
<body>
<h1>MipSmooth</h1>
<h2>Abstract</h2>
<b>author:</b> Klaus Post (Sh0dan)
<br><b>version:</b>     1.11<br>
<b>download:</b> http://cultact-server.novi.dk/kpo/avisynth/mipsmooth.html
<br><b>category:</b>  Spatio-Temporal Smoothers
<br><b>requirements:</b>&nbsp;
<ul>
  <li>YV12 &amp; YUY2 &amp; RGB Colorspace</li>
  <li>ISSE support</li>
  <li>width divisible by 4 for YV12 and by 8 for YUY2</li>
</ul>

<hr size=2 width="100%" align=center>

<h2>Description</h2>
<p>
This is the MipSmoother -
a reinvention of SmoothHiQ and Convolution3D. MipSmooth was made to enable
smoothing of larger pixel areas than 3x3(x3), to remove blocks and smoothing out
low-frequency noise. It is my hope that when
this filter has been tweaked it will be better than C3D at smoothing out flat
surfaces and gradients. This should be good for cartoons/anime, but it actually
also helps film footage quite nicely.</p>
<h2>
<small>Syntax</small>
</h2>
<p>Basic syntax: <code>MipSmooth</code> - all parameters are optional.</p>
<p>Extended syntax:</p>
<p><code>MipSmooth</code> (<var>clip, optional arguments</var>)
</p>
<p>There are a number of
arguments that control how much smoothing will be applied:
</p>
<p><var>preset</var> = &quot;MovieHQ&quot; / &quot;MovieLQ&quot; / &quot;AnimeHQ&quot; /
&quot;AnimeLQ&quot; / &quot;VHS&quot; / &quot;Rainbow&quot; / &quot;Custom&quot;
</p>
<p>Loads a built-in preset
as new defaults. See the preset section for more information.
</p>
<pre>spatial = 5,
temporal = 4,
spatial_chroma =6,
temporal_chroma =54,
scenechange = 2.0</pre>
<p>All numbers are valid in
the ranges 0 - 255 and this defines the threshold for each mode of blending.<br>
The thresholds can be
compared to the ones of C3D, except higher thresholds smooth much less than C3D.<br>
The default settings are
quite conservative, and only slightly smooths out surfaces.
</p>
<p>&quot;Temporal
influence&quot; is replaced by overall scenechange detection.&nbsp; Scenechanges
will disable temporal processing in either direction. Use &quot;<var>show</var> =
true&quot; to display the values on each frame.
</p>
<p><var>method&nbsp;</var> = &quot;strong&quot; / &quot;soft&quot; /&nbsp; &quot;supersoft&quot; /
&quot;superstrong&quot;&nbsp; -&nbsp;
default: &quot;supersoft&quot;<br>
This setting controls how
much blurring is applied. The strong
settings makes the filter have a larger impact, whereas soft
is more gentle. In general strong
should give best results on anime, and soft
should be best for filmed material.<br>
SuperSoft / SuperStrong uses a slightly
different approach, and in general leads to fewer artifacts. These two are an
general a bit softer than non-super modes.
</p>
<p><var>downsizer</var>
= &quot;reduce&quot;, &quot;point&quot;, &quot;bilinear&quot;,
&quot;bicubic&quot;, &quot;lanczos&quot;&nbsp; -&nbsp;
default: &quot;reduce&quot;<br>
<var>upsizer</var>
= &quot;point&quot;, &quot;bilinear&quot;, &quot;bicubic&quot;,
&quot;lanczos&quot;&nbsp; -&nbsp;
default: &quot;bilinear&quot;<br>
These two parameters
control how the lower resolution maps are created. There might not be a very big
visual impact, when using different resizers. Experiments are welcome!
</p>
<p><var>scalefactor</var>
= 0.5<br>
This option sets the
scale of each mipmap. This is how much each frame is reduced in each iteration.
The original resolution is multiplied by this value.&nbsp; Usable values are
from 0.2 to 4.0, however only values between 0.4 and 1.5 are recommended. When
this setting is 1.0 no spatial blurring is done, but this isn't recommended -
use spatial = 0 instead. Experiment with values above 1.0 - they might be
useful.<br>
This affects the radius of the blur. The lower the scalefactor is, the bigger
the radius of the blur - and the more crosstalk you'll get.
</p>
<pre>MipSmooth(downsizer=&quot;lanczos&quot;, upsizer=&quot;bilinear&quot;, scalefactor=1.5, method = &quot;strong&quot;)</pre>
<p>The above script produces very nice gentle smoothing for instance, but is
very slow.
</p>
<p><var>weigh</var>
= true / false<br>
This option selects
whether mips should be weighed based on how blurred they are.&nbsp; The most
blurred mips are weighed the lowest.&nbsp; This option is equal to &quot;Weighed
Average&quot; in SmoothHiQ, or &quot;soft&quot; matrix in Convolution3D.
</p>
<p>This option has only effect if SuperMip-mode is used.&nbsp; It reduces the
amount of blur when turned on, so it can be used to achieve higher thresholds
without artifacts.
</p>
<p><var>show</var> =
true / false<br>
Shows information about
scenechange differences, and the settings being used.<br>
This setting will have no effect in RGB24 mode - use RGB32 instead!
</p>
<p><var>storecustom</var>
= true / false<br>
This will store the
settings being used in the registry.<br>
To reinvoke these presets
later, use <var>preset</var> = &quot;custom&quot; parameter.<br>
This will not automatically become the default parameters.
</p>
<h2>Presets
</h2>
<p>Presets
are a set of builtin settings to help you get started. The names of the
parameters are not case sensitive.</p>
<p>All presets are loaded as default values. That means that it is still possible
to finetune preset settings by setting individual parameters.</p>
<p>For example: MipSmooth(preset
= &quot;movieHQ&quot;, scenechange = 8)
will use the MovieHQ, but with scenechange set to 8.</p>
<p><b>MovieHQ</b></p>
<p>This preset is for natual movies in high quality.</p>
<pre>Spatial: 4
Temporal: 5
Spatial Chroma: 5
Temporal Chroma: 7
Scenechange: 2.0
Method: SuperSoft
Downsizer: Bilinear
Upsizer: Bilinear
Scalefactor: 0.85
Weigh = true</pre>
<b>
MovieHQ2</b>
<p>This preset is for natual movies in high quality.</p>
<pre>Spatial: 2
Temporal: 2
Spatial Chroma: 3
Temporal Chroma: 3
Scenechange: 2.5
Method: SuperSoft
Downsizer: Bilinear
Upsizer: Bilinear
Scalefactor: 0.75
Weigh = true</pre>
<b>
MovieLQ</b>
<p>This
preset is for natural movies that need more smoothing, to have more blocks and
noise removed.</p>
<pre>Spatial: 8
Temporal: 7
Spatial Chroma: 10
Temporal Chroma: 8
Scenechange: 3.5
Method: SuperSoft
Downsizer: Bilinear
Upsizer: Bilinear
Scalefactor: 0.65
Weigh = true
</pre>
<b>MovieLQ2</b>
<p>
This preset is for
natural movies that need more smoothing, to have more blocks and noise removed.</p>
<pre>Spatial: 4
Temporal: 4
Spatial Chroma: 5
Temporal Chroma: 5
Scenechange: 3.5
Method: SuperStrong
Downsizer: Bilinear
Upsizer: Bilinear
Scalefactor: 0.65
Weigh = true</pre>

<b>VHS</b>
<pre>Spatial: 9
Temporal: 6
Spatial Chroma: 10
Temporal Chroma: 9
Scenechange: 5.0
Method: SuperStrong
Downsizer: Bilinear
Upsizer: Bilinear
Scalefactor: 0.60
Weigh = true
</pre>
<b>AnimeHQ</b>
<p>This is for slight blockremoval and gradient restoration. It has more spatial
smoothing than ordinary video to help recreate flat and gradient surfaces.</p>
<pre>Spatial: 6
Temporal: 8
Spatial Chroma: 6
Temporal Chroma: 8
Scenechange: 5.0
Method: SuperSoft
Downsizer: Bicubic
Upsizer: Bicubic
Scalefactor: 0.60
Weigh = true
</pre>
<b>AnimeLQ</b>
<p>This is for more noisy
material with more blocks and noise.</p>
<pre>Spatial: 5
Temporal: 5
Spatial Chroma: 5
Temporal Chroma: 7
Scenechange: 5.5
Method: SuperStrong
Downsizer: Bilinear
Upsizer: Bicubic
Scalefactor: 0.5
Weigh = true
</pre>
<b>Rainbow</b>
<p>This
might help removing rainbow flicker. See <a href="http://forum.doom9.org/showthread.php?s=&amp;threadid=62873">this
thread at Doom9</a> for info and alternatives. Reduce scalefactor for even more
rainbow removal, but more chroma blurring.</p>
<pre>Spatial: 0
Temporal: 0
Spatial Chroma: 255
Temporal Chroma: 255
Scenechange: 2.0
Method: SuperStrong
Downsizer: Bilinear
Upsizer: Bilinear
Scalefactor: 0.65
Weigh = true
</pre>
<b>Custom</b>
<p>This will
read settings that has been stored in the registry, and use these as default
settings.<br>
If there is no settings stored in the registry, an error will be thrown.<br>
At any time it is possible to use &quot;<var>storecustom</var> = true&quot;
this will then store the current settings in the registry, and these will then
be used as the custom parameters</p>
<h2>Examples &amp;
Tricks:</h2>
Try experimenting with quite hard softening with very low thresholds. For
example:
<pre>MipSmooth(spatial=2, temporal=2, method=&quot;superstrong&quot;, scalefactor=0.75, weigh=true)</pre>
<p>This is a quite good setting for high quality material, which will stabilize the
image and give much better compression and still retaining a quite high amount
of detail. These modes are implemented as &quot;MovieHQ2&quot; and
&quot;MovieLQ2&quot; presets.</p>
<pre>MipSmooth(spatial=255, scenechange=0, method=&quot;soft&quot;)
# This will give a very soft image - seen in some commercials and soap operas.</pre>
<pre>MipSmooth(spatial=255, scenechange=0, method=&quot;strong&quot;, scalefactor=0.65)
# This will smooth the image very much like a soft gaussian blur.</pre>
<pre>MipSmooth(spatial=255, scenechange=255, temporal=255, method=&quot;superstrong&quot;, scalefactor=0.6, weigh=false)
# This will also give a very soft image with some temporal blurring.</pre>
<p>When cropping right before this filter, use &quot;align=true&quot; parameter,
available in AviSynth 2.5.3 and later. This will in most cases give a slight
speedup.</p>
<h2>Background information</h2>
&quot;Mip&quot; comes
from &quot;MipMap&quot;, which is a term used in the realtime 3D-graphics world,
and basicly describes a downsampled version of a texture (bitmap surfaces of 3D
objects), that is used, when the object is far away.&nbsp; MipMaps are always
half the size of the original image.
<p>What MipSmooth does is
actually very simple:</p>
<p>It takes the source
frame, and creates three new versions, each half the size of the previous. This
is done by using <a href="../corefilters/reduceby2.htm">ReduceBy2</a>,
or a selectable <a href="../corefilters/resize.htm">resizer</a>. These frames are then all scaled back up to original
size using BilinearResize.&nbsp;
These frames are then compared to the original, and if the difference is below
the threshold, the information is used to form the final pixel.</p>
<p>The same is done to the
previous and the next frame - and all these three frames and their
&quot;blurred&quot; mipmaps are used to reconstruct each pixel.<br>
Threshold is adjusted to
that more blurred images are given a lower threshold than the sharper versions.</p>
<p>Supermip first creates three frames (supermips) from spatially blurred images
and does a temporal softening on these three framres. This greatly reduces
artifacts on heavy denoising/blurring.</p>
<h2>Further possible improvements</h2>
<ul style="font-family: helvetica,arial,sans-serif;">
  <li>Adjustable number of mips.</li>
  <li>Image examples in documentation.</li>
  <li>GUI.
  </li>
</ul>
<p><kbd>$Date: 2004/08/13 21:57:25 $</kbd></p>
</body>
</html>
